<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="drawingsset" lay-title="代理佣金设置">
  <div class="layui-fluid layui-form">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
		  <div class="layui-card-header">代理佣金设置</div>
          <div class="layui-card-body hxr-card-body" style="padding: 15px;">
			<div class="layui-form-item">
			  <label class="layui-form-label">佣金比例</label>
			  <div class="layui-input-inline">
				<input type="number" style="display: inline-block;width: 90%;" v-model="detail.key_value" autocomplete="off" lay-verify="required" class="layui-input" placeholder="请输入佣金比例">%
			  </div>
			</div>
			<div class="layui-form-item">
			  <label class="layui-form-label">是否启用</label>
			  <div class="layui-input-inline">
				 <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'启用':'停用'}}</em><i></i></div>
			  </div>
			</div>
			<div class="layui-form-item">
			  <label class="layui-form-label"></label>
			  <div class="layui-input-inline">
				<button type="button" class="layui-btn" lay-submit style="width: 190px;" lay-filter="form-submit">保存</button>
			  </div>
			</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<style type="text/css">
#drawingsset .layui-form-label{
	width: 150px;
}
</style>
<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var vm=new Vue({
	  	  el:'#drawingsset',
	  	  data:{
	  		  detail:{
	  			 status:2
	  		  },
	  		  old_detail:{}
	  	  },
	  	  mounted:function() {
			  //初始化
			  var _this=this;
	  	  	layui.admin.ajax('withdraw/get_congfig',{},1).then(function(res){
				res.data.status?res.data.status:res.data.status=2;
				_this.detail=res.data,_this.old_detail=JSON.stringify(res.data);
	  	  	});
			//提交form
			form.on('submit(form-submit)',function(data){
				if(_this.detail.key_value<0||_this.detail.key_value>100){
				  return layui.admin.ahint(2,'请输入0到100之间的数字');
				}
				var data=layui.admin.filter(_this.detail,JSON.parse(_this.old_detail));
				if(data){
					layui.admin.ajax('withdraw/set_congfig',data).then(function(res){
						_this.old_detail=JSON.stringify(_this.detail);
					});
				}else{
					layer.msg('无修改');
				}
			})
	  	  },
	  	  methods:{
	  		  radioF:function(){//radio选择
	  		  	this.detail.status==1?this.detail.status=2:this.detail.status=1;
	  		  }
	  	  }
	  })
	})
</script>